package com.springboot.in.action.controller

import org.springframework.beans.factory.annotation.Autowired
import org.springframework.ui.Model
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.servlet.ModelAndView
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.bind.annotation.PathVariable
import com.cssiot.scala.dao.inf.HttpReportDao
import com.cssiot.scala.dao.inf.GzzInfoTestDao
import com.cssiot.scala.entity.Gzz01InfoTest

@RestController
@RequestMapping(Array("/httpreport"))
class HttpReportController @Autowired()(val HttpReportDao: HttpReportDao,val gzzInfoTestDao:GzzInfoTestDao) {

  @RequestMapping(value = { Array("", "/") })
  def list(model: Model) = {
    new ModelAndView("/httpreport/list")
  }
  
   @RequestMapping(value = Array("/postnew"), method = Array(RequestMethod.POST))
  @ResponseBody
  def newOne(@RequestParam(value = "name") name: String) = {
    val p = new Gzz01InfoTest
    gzzInfoTestDao.saveObject(p)
  }
   
    /**
    * 项目下面的用例编辑
    */
  @RequestMapping(Array("/editPage/{caseId}"))
  def goEditPage(model: Model, @PathVariable(value = "caseId") caseId: Integer, @RequestParam(value = "httpSuiteId") httpSuiteId: Integer) = {
    val httpapi = gzzInfoTestDao.findById(caseId)
    model.addAttribute("httpapi", httpapi)
    model.addAttribute("httpSuiteId", httpSuiteId)
    new ModelAndView("/httpapi/edit")
  }

}
